package com.zbkj.crmeb.merchant.admin.controller;

import com.crmeb.core.common.CommonResult;
import com.utils.vo.dateLimitUtilVo;
import com.zbkj.crmeb.store.response.DataLiveResponse;
import com.zbkj.crmeb.store.service.CustomerProfileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("api/admin/mer/customer/profile")
@Api(tags = "客户概况")
public class MerCustomerProfileController extends AdminBaseController{

    @Autowired
    private CustomerProfileService customerProfileService;

    /**
     * 功能描述: 客户概况
     * @Param: [dateLimit, servletRequest]
     * @Return: com.crmeb.core.common.CommonResult<java.util.Map<java.lang.String,java.lang.Object>>
     * @Author: wangzh
     * @Date: 2023/1/6 10:25
     */
    @ApiOperation("客户概况")
    @GetMapping("/customerProfileBoard")
    public CommonResult<Map<String, Object>> customerProfileBoard(dateLimitUtilVo dateLimit, HttpServletRequest servletRequest){
        return CommonResult.success(customerProfileService.customerProfileBoard(dateLimit, getMerId(servletRequest)));
    }

    /**
     * 功能描述: 客户成交
     * @Param: [dateLimit, servletRequest]
     * @Return: com.crmeb.core.common.CommonResult<com.zbkj.crmeb.store.response.DataLiveResponse>
     * @Author: wangzh
     * @Date: 2023/1/6 10:27
     */
    @ApiOperation("客户成交")
    @GetMapping("/customerMakeDeal")
    public CommonResult<DataLiveResponse> customerMakeDeal(dateLimitUtilVo dateLimit, HttpServletRequest servletRequest){
        return CommonResult.success(customerProfileService.customerTransaction(dateLimit, getMerId(servletRequest)));
    }

    /**
     * 功能描述: 按类型统计成交用户概况
     * @Param: [dateLimit, servletRequest]
     * @Return: com.crmeb.core.common.CommonResult<java.util.Map<java.lang.String,java.lang.Object>>
     * @Author: wangzh
     * @Date: 2023/1/6 15:35
     */
    @ApiOperation("成交用户概况（类型）")
    @GetMapping("/type")
    public CommonResult<Map<String, Object>> customerTransactionByType(dateLimitUtilVo dateLimit, HttpServletRequest servletRequest){
        return CommonResult.success(customerProfileService.customerTransactionByType(dateLimit, getMerId(servletRequest)));
    }

    @ApiOperation("成交用户概况（时间）")
    @GetMapping("/date")
    public CommonResult<Map<String, Map<String, Object>>> customerTransactionByDate(HttpServletRequest request){
        return CommonResult.success(customerProfileService.customerTransactionByDate(getMerId(request)));
    }

}
